package com.ruoyi.oss.service.impl;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.oss.domain.SysOss;
import com.ruoyi.oss.domain.bo.UploadResult;
import com.ruoyi.oss.service.CloudOssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class DefaultCloudOssService implements CloudOssService {

    /**
     * 上传文件至OSS
     *
     * @param multipartFile 多部份文件
     * @param fileSuffix    文件后缀
     * @return 上传文件的结果
     */
    @Override
    public UploadResult upload(MultipartFile multipartFile, String fileSuffix) {
        throw new ServiceException("请配置云OSS服务!");
    }

    /**
     * 下载文件
     *
     * @param sysOss              文件上传记录
     * @param httpServletRequest  请求
     * @param httpServletResponse 响应
     * @return 响应体
     */
    @Override
    public ResponseEntity<StreamingResponseBody> download(SysOss sysOss, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        throw new ServiceException("请配置云OSS服务!");
    }
}
